import java.util.Random;
import java.util.Scanner;

/**
 *
 */
public class T20250318 {
    public static void test() {
        int a = 1;
        byte c = 2;
        float b = a;
        String e = "dun";
        String f = a + "";
        e = e + " ";
        System.out.println(e + "guang" + " " + f);
        System.out.println(Integer.MAX_VALUE);
        System.out.println(Character.MIN_VALUE);
    }

    public static void guess_Number() {
        Scanner sc = new Scanner(System.in);
        Random random = new Random();
        int start, end, num, guess, i;
        while (true) {
            System.out.print("随机数生成范围: ");
            start = sc.nextInt();
            end = sc.nextInt();
            num =start + random.nextInt(end + 1 - start);
            for (i = 2; i >= 0 ; i--) {
                System.out.print("请输入要猜的数字" + "(" + start + "~" + end + ")" + ": ");
                guess = sc.nextInt();
                if (guess == num) {
                    System.out.println("猜对了!!!");
                    break;
                } else if (guess > num) {
                    System.out.println("猜大了");
                } else {
                    System.out.println("猜小了");
                }
                System.out.println("你还有" + i + "次机会");
            }
            if (i == -1) {
                System.out.println("游戏挑战失败");
            }
        }
    }

    public static void move(char p1, char p3) {
        System.out.print(p1 + "->" + p3 + " ");
    }

    public static void hnt(int n, char p1, char p2, char p3) {
        if (n == 1) {
            move(p1, p3);
            return ;
        }
        hnt(n-1, p1, p3, p2);
        move(p1, p3);
        hnt(n-1, p2,  p1, p3);
    }

    public static void test2() {
        int count = 0;
        for (int n = 2,i; n <= 100 ; n++) {
            for (i = 2; i <= Math.sqrt(n) ; i++) {
                if (n % i == 0) {
                    break;
                }
            }
            if (i > Math.sqrt(n)) {
                count++;
                System.out.print(n + " ");
            }
        }
        System.out.printf("\ncount = %d", count);
    }

    public static void test3() {
        int count = 0;
        for (int y = 1000; y <= 2000; y++) {
            if (y % 400 == 0 || y % 4 == 0 && y % 100 != 0) {
                System.out.print(y + " ");
                count++;
            }
        }
        System.out.printf("\ncount: %d", count);
    }

    public static void test4() {
        int count = 0;
        for (int n = 1; n <= 100 ; n++) {
            if (n % 10 == 9 || n / 10 == 9) {
                count++;
            }
        }
        System.out.println("count: " + count);
    }

public static void test5() {
        Scanner sc = new Scanner(System.in);
        int a, b, c;
        System.out.print("输入两个正整数: ");
        a = sc.nextInt();
        b = sc.nextInt();
        c = a % b;
        while (c != 0) {
            a = b;
            b = c;
            c = a % b;
        }
    System.out.println("最大公约数: " + b);
}

public static void test6() {
        int sum = 0;
    for (int n = 1, fs = -1; n <= 100 ; n++) {
        sum += fs*-1/n;
    }
    System.out.println("sum: " + sum);
}

public static void test7() {
    for (int n = 100; n < 1000; n++) {
        int sum = 0, ns = n;
        while(ns != 0) {
            sum += Math.pow(n%10, 3);
            ns/=10;
        }
        if (sum == n) {
            System.out.println(n + " ");
        }
    }
}

public static void test8() {
        Scanner sc = new Scanner(System.in);
        Random random = new Random();
        int guess, num = 1 + random.nextInt(7);
        while (true) {
            System.out.print("请猜数字(1~7): ");
            guess = sc.nextInt();
            if (guess == num) {
                System.out.println("恭喜,猜对了!!!");
                break;
            } else if (guess < num) {
                System.out.println("猜小了");
            } else {
                System.out.println("猜大了");
            }
        }
}

public static void test9() {
    for (int i = 0; i < 5; i++) {
        for (int j = 0; j < 5; j++) {
            if (i == j || i + j == 4) {
                System.out.print("*");
            } else {
                System.out.print(" ");
            }
        }
        System.out.println();
    }

}

public static void test10() {
        Scanner sc = new Scanner(System.in);
    System.out.print("输入: ");
        int n = sc.nextInt();
        while (n != 0) {
            System.out.print(n%10);
            if (n > 9) {
                System.out.print(", ");
            }
            n /= 10;
        }
}

public static void test11() {
        Scanner sc = new Scanner(System.in);
        String passWord = "12345";
        String sr = null;
    for (int n = 2; n >= 0;) {
        System.out.print("请输入密码: ");
        sr = sc.nextLine();
        if (passWord.equals(sr)) {
            System.out.println("登陆成功!!!");
            break;
        } else {
            System.out.println("密码输入错误,还有" + n + "次机会");
            n--;
            if (n == -1) {
                System.out.println("退出程序");
            }
        }
    }
}

public static int fact(int n) {
        int sum = 1;
        if (n == 0 || n == 1) {
            return sum;
        }
    for (int i = 2; i <= n ; i++) {
        sum *= i;
    }
    return sum;
}

public static void test12() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), sum = 0;

    for (int i = 1; i <= n ; i++) {
        sum += fact(i);
    }
    System.out.println("sum: " + sum);
}

public static void fib() {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt(), a = 1, b = 1, sum = 0;
        if (n ==1 || n == 2) {
            sum = 1;
        } else {
            for (int i = 3; i <= n ; i++) {
                sum = a + b;
                a = b;
                b = sum;
            }
        }
    System.out.println("fib(" + n + "): " + sum);
}

public static int max_Num(int a, int b) {
        return a > b ? a : b;
}

public static double max_Num(double a, double b, double c) {
        return (a > b ? a : b) > c ? (a > b ? a : b) : c;
}

    public static void main(String[] args) {
//        guess_Number();
//        hnt(3,'a', 'b', 'c');
//        System.out.println(Byte.MAX_VALUE);
//        test2();
//        test3();
//        test4();
//        test5();
//   test6();
//        test7();
//        test8();
//        test9();
//        test10();
//        test11();
//        test12();
//        fib();
    }
}
